package Reflect;

import Reflect.annotation.AutoRunMethod;

import java.lang.reflect.Method;

public class Test5 {
    public static void main(String[] args) throws Exception {
        Class cla=Class.forName("Reflect.Person");
        Method[] methods=cla.getMethods();
        for (Method method:methods){
            if (method.isAnnotationPresent(AutoRunMethod.class)){
                Object obj=cla.newInstance();
                int value=method.getAnnotation(AutoRunMethod.class).value();
                System.out.println("调用方法:"+method.getName()+"次数:"+value);
                for (int i=0;i<value;i++){
                    method.invoke(obj);
                }
            }
        }
    }
}




















